<template>
    <div class="container">
        <!-- 导航条 -->
        <div class="nav-bar">
            <template v-for="item in navList" :key="item.name">
                <div class="nav-item" :class="{
                    active: route.path === item.path,
                }" @click="item.click ? item.click() : jumpPath(item.path)" v-if="item.show">
                    {{ item.name }}
                </div>
            </template>
            <div v-if="userStore.userInfo.level == 3" class="nav-item" @click="onBackend">
                后台管理
            </div>
        </div>

        <div class="main">
            <!-- <div class="right-box"> -->
            <slot />
            <!-- </div> -->
        </div>
    </div>
</template>
<script setup>
import { useContent } from ".";

const route = useRoute();
const userStore = useUserStore();
const { navList } = useContent();

const jumpPath = (path) => navigateTo(path);

const onBackend = () => {
    window.open("https://marketing.vrnewg.com");
};
</script>
<style lang="scss" scoped>
.container {
    width: 100%;
    height: calc(100vh - 70px);
    background: url("https://yzpt-resources.oss-cn-hangzhou.aliyuncs.com/web/images/admin/bg.jpg") no-repeat #edf5fa;
    background-size: 100% auto;
    padding-top: 50px;
}

.nav-bar {
    display: flex;
    width: 1200px;
    margin: 0 auto;

    .nav-item {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 120px;
        height: 44px;
        border-radius: 8px;
        font-size: 18px;
        color: #333;
        cursor: pointer;

        &.active {
            background: #5085fb;
            color: #fff;
            font-weight: bold;
        }
    }
}

.main {
    display: flex;
    width: 1200px;
    height: calc(100% - 44px - 20px - 30px);
    margin: 20px auto 0;
    // padding-bottom: 30px;
    overflow: hidden;
    background-color: #fff;
    border-radius: 6px;
    overflow: auto;

    .right-box {
        width: 906px;
        height: 100%;
        overflow: auto;
        background: #fafafb;
    }
}
</style>
